package o;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.RadialGradient;
import android.graphics.Shader.TileMode;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.OvalShape;
import android.os.Build.VERSION;
import android.view.animation.Animation.AnimationListener;
import android.widget.ImageView;
import androidx.core.view.ViewCompat;

public class mz extends ImageView {
    private AnimationListener ˊ;
    int ॱ;

    class e extends OvalShape {
        private Paint ˊ = new Paint();
        final /* synthetic */ mz ˋ;
        private RadialGradient ˎ;

        e(mz mzVar, int i) {
            this.ˋ = mzVar;
            mzVar.ॱ = i;
            ˎ((int) rect().width());
        }

        protected void onResize(float f, float f2) {
            super.onResize(f, f2);
            ˎ((int) f);
        }

        public void draw(Canvas canvas, Paint paint) {
            int width = this.ˋ.getWidth();
            int height = this.ˋ.getHeight();
            canvas.drawCircle((float) (width / 2), (float) (height / 2), (float) (width / 2), this.ˊ);
            canvas.drawCircle((float) (width / 2), (float) (height / 2), (float) ((width / 2) - this.ˋ.ॱ), paint);
        }

        private void ˎ(int i) {
            this.ˎ = new RadialGradient((float) (i / 2), (float) (i / 2), (float) this.ˋ.ॱ, new int[]{1023410176, 0}, null, TileMode.CLAMP);
            this.ˊ.setShader(this.ˎ);
        }
    }

    public mz(Context context, int i) {
        Drawable shapeDrawable;
        super(context);
        float f = getContext().getResources().getDisplayMetrics().density;
        int i2 = (int) (1.75f * f);
        int i3 = (int) (0.0f * f);
        this.ॱ = (int) (3.5f * f);
        if (ˏ()) {
            shapeDrawable = new ShapeDrawable(new OvalShape());
            ViewCompat.ˋ(this, f * 4.0f);
        } else {
            shapeDrawable = new ShapeDrawable(new e(this, this.ॱ));
            setLayerType(1, shapeDrawable.getPaint());
            shapeDrawable.getPaint().setShadowLayer((float) this.ॱ, (float) i3, (float) i2, 503316480);
            int i4 = this.ॱ;
            setPadding(i4, i4, i4, i4);
        }
        shapeDrawable.getPaint().setColor(i);
        ViewCompat.ˏ(this, shapeDrawable);
    }

    private boolean ˏ() {
        return VERSION.SDK_INT >= 21;
    }

    protected void onMeasure(int i, int i2) {
        super.onMeasure(i, i2);
        if (!ˏ()) {
            setMeasuredDimension(getMeasuredWidth() + (this.ॱ * 2), getMeasuredHeight() + (this.ॱ * 2));
        }
    }

    public void setAnimationListener(AnimationListener animationListener) {
        this.ˊ = animationListener;
    }

    public void onAnimationStart() {
        super.onAnimationStart();
        if (this.ˊ != null) {
            this.ˊ.onAnimationStart(getAnimation());
        }
    }

    public void onAnimationEnd() {
        super.onAnimationEnd();
        if (this.ˊ != null) {
            this.ˊ.onAnimationEnd(getAnimation());
        }
    }

    public void setBackgroundColorRes(int i) {
        setBackgroundColor(fo.ˋ(getContext(), i));
    }

    public void setBackgroundColor(int i) {
        if (getBackground() instanceof ShapeDrawable) {
            ((ShapeDrawable) getBackground()).getPaint().setColor(i);
        }
    }
}
